
#include    "test/logger.hpp"

#include    "antc/antc.hpp"

using namespace ant;
using namespace help;
using namespace antc;

int     do_test(Antc* pAntc)
{
    const char* pszServer = "127.0.0.1";
    int     iPort = 4344;
    
    Logger& logger = Logger::getInstance();
    
    try {
        pAntc->connect(pszServer, iPort);
    }
    catch(Exception& ex) {
        logger.error(__FILE__, __LINE__, "fail to connect : %s", ex.what());
        return  -1;
    }
    
    try {
        pAntc->disconnect();
    }
    catch(Exception& ex) {
        logger.error(__FILE__, __LINE__, "fail to disconnect : %s", ex.what());
        return  -2;
    }
    
    return  0;
}

int     main(int argc, char* argv[])
{
    Logger& logger = Logger::getInstance();
    
    logger.info( "==== Test BEGIN ====" );
    
    Antc*   pAntc = NULL;
    try {
        pAntc = Antc::create(Antc::UDP);
    }
    catch(Exception& ex) {
        logger.error("fail to instance Antc : %s", ex.what());
        return  1;
    }
    
    do_test(pAntc);
    
    logger.info( "==== Test  END  ====" );
    
    return  0;
}

